const mongoose = require('mongoose');

const deployLogSchema = new mongoose.Schema({
  projectId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Project',
    required: true
  },
  status: {
    type: String,
    enum: ['running', 'success', 'failed'],
    default: 'running'
  },
  startTime: {
    type: Date,
    default: Date.now
  },
  endTime: Date,
  logs: {
    type: [{
      timestamp: {
        type: Date,
        default: Date.now
      },
      level: {
        type: String,
        enum: ['info', 'warning', 'error']
      },
      message: String
    }],
    default: []
  },
  branch: String,
  commitId: String,
  deployedBy: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User'
  }
});

module.exports = mongoose.model('DeployLog', deployLogSchema); 